part of _;

extension on ShowPicturePage {
  Widget view_gallery() {
    return GestureDetector(
      child: Container(
        color: Colors.black,
        child: PhotoViewGallery.builder(
          pageController: pageController,
          scrollPhysics: BouncingScrollPhysics(),
          backgroundDecoration: BoxDecoration(color: Colors.black),
          onPageChanged: (page) => setState(() => index = page),
          enableRotation: false,
          itemCount: pictures.length,
          loadingBuilder: (context, event) => Center(
            child: Container(
              width: 20.0,
              height: 20.0,
              child: CircularProgressIndicator(value: event == null ? 0 : event.cumulativeBytesLoaded / event.expectedTotalBytes!),
            ),
          ),
          builder: (context, index) {
            ImageProvider imageProvider_File = FileImage(File(pictures[index]));
            ImageProvider imageProvider_Net = ExtendedNetworkImageProvider(pictures[index]);
            return PhotoViewGalleryPageOptions(
              imageProvider: (pictures[index].startsWith("http://") || pictures[index].startsWith("https://")) ? imageProvider_Net : imageProvider_File,
              initialScale: PhotoViewComputedScale.contained,
              minScale: PhotoViewComputedScale.contained,
              maxScale: PhotoViewComputedScale.covered * 2,
            );
          },
        ),
      ),
      onTap: () => yFinish(),
      onLongPress: () => controller_showActions(),
    );
  }

  Widget view_top() {
    return Positioned(
      top: yStatubarHeight() + 10,
      left: 10,
      child: YInkRoundButton(Icon(Icons.close, color: Colors.white), onTap: () => yFinish()),
    );
  }

  Widget view_num() {
    if (pictures.length <= 1) return YEmpty();
    return Positioned(
      right: 10,
      bottom: ySafeAreaBottomHeight() + 10,
      child: Container(
        padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
        decoration: BoxDecoration(color: Colors.black.withAlpha(100), borderRadius: BorderRadius.circular(99)),
        child: Text("${index + 1}/${pictures.length}", style: TextStyle(color: Colors.white, fontSize: 12)),
      ),
    );
  }
}
